package com.zhixin.fans.ks.ui.user;

import android.content.Intent;
import android.view.View;

import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton;
import com.zhixin.fans.ks.R;
import com.zhixin.fans.ks.manager.UserInfoManager;
import com.zhixin.fans.ks.ui.base.BaseNeedLoginActivity;
import com.zhixin.fans.ks.ui.main.MainActivity;

import org.eenie.common.views.TopBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;


public class UserDetailActivity extends BaseNeedLoginActivity {
    public static final String ROUTE_PATH = "/user/user_detail";
    @BindView(R.id.top_bar)
    TopBarLayout mTopBar;
    @BindView(R.id.btn_logout)
    QMUIRoundButton mBtnLogout;


    UserInfoManager mUserInfoManager;


    @Override
    public int initContentView() {
        return R.layout.activity_user_detail;
    }

    @Override
    public void initInjector() {
        mUserInfoManager = getCoupleAppComponent().getUserInfoManager();
    }

    @Override
    public void initUiAndListener() {
        ButterKnife.bind(this);

        mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        mBtnLogout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new QMUIDialog.MessageDialogBuilder(mContext)
                        .setTitle("提示")
                        .setMessage("确定退出登录？")
                        .addAction("取消", new QMUIDialogAction.ActionListener() {
                            @Override
                            public void onClick(QMUIDialog dialog, int index) {
                                dialog.dismiss();
                            }
                        })
                        .addAction("确定", new QMUIDialogAction.ActionListener() {
                            @Override
                            public void onClick(QMUIDialog dialog, int index) {
                                dialog.dismiss();
                                mUserInfoManager.logout();

                                startActivity(new Intent(mContext, MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK));


                            }
                        })
                        .create().show();
            }
        });


    }


}
